<template>
    <div v-loading="loading" class="addgroup">
        <el-form v-if="!loading" ref="form" :model="form" label-width="80px">

            <el-form-item label="权限名称">
                <el-input v-model="form.title"></el-input>
            </el-form-item>

            <el-form-item label="权限描述">
                <el-input v-model="form.description"></el-input>
            </el-form-item>
            <el-form-item label="是否显示">
                <el-switch v-model="form.status" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
            </el-form-item>
            <el-form-item label="">
                <el-button style="width: 100px;" type="primary" @click="GetSubmit()">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
export default {
    name: "edit",
    props: {
        editData: {
            type: Object
        },
        dialogVisibleEdit: {
            type: Boolean
        }
    },
    data() {
        return {
            loading: true,
            form: {
                title: '',
                description: '',
                status: true,
                id: 0
            },
        }
    },

    mounted() {
        setTimeout(() => {
            this.form.id = this.editData.id
            this.form.title = this.editData.title
            this.form.description = this.editData.description
            if (this.editData.status == 1) {
                this.form.status = true
            } else {
                this.form.status = false
            }

            this.loading = false
        }, 200)

    },
    methods: {
        // 提交
        GetSubmit() {
            let that = this

            let form = that.form

            if (form.title == '') {
                this.$Msg.message("权限名称不能为空", "error");
                return
            }
            if (form.description == '') {
                this.$Msg.message("栏目目录不能为空", "error");
                return
            }

            let status = 0;

            if (form.status == true) {
                status = 1
            } else {
                status = 0
            }
            form.status = status


            that.loading = true

            this.$http.HttpPost("v1/GetUpdateGroup", form).then((res) => {
                if (res.code == 0) {
                    that.$Msg.message(res.msg)
                    that.loading = false
                    that.$emit('initPageData')

                }
            })

        },

        clearForm() {
            this.form.title = ''
            this.form.description = ''
            this.form.status = true
        }
    }

}
</script>

<style scoped>
.content {
    width: 600px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    height: 200px !important;
    overflow: scroll !important;

}

.contents {
    width: 200px !important;

    height: 200px !important;
    overflow: scroll !important;

}

.content p {
    width: 50%;
    padding-left: 3%;
    height: 30px;
    cursor: pointer;
    width: 30%;
    border: 1px solid transparent;
    font-size: 14px;
    align-items: center;
    display: flex;
    justify-content: left;
    text-align: center

}

.iconActive {
    border: 1px solid #ccc !important;
}
</style>
